---
title: Azure Container Apps Dynamic Sessions
---

> [Azure Container Apps dynamic sessions](https://learn.microsoft.com/azure/container-apps/sessions) provide fast access to secure sandboxed environments that are ideal for running code or applications that require strong isolation from other workloads.

You can learn more about Azure Container Apps dynamic sessions and its code interpretation capabilities on [this page](https://learn.microsoft.com/azure/container-apps/sessions). If you don't have an Azure account, you can [create a free account](https://azure.microsoft.com/free/) to get started.

## Setup

You'll first need to install the [`@langchain/azure-dynamic-sessions`](https://www.npmjs.com/package/@langchain/azure-dynamic-sessions) package:

import IntegrationInstallTooltip from '/snippets/javascript-integrations/integration-install-tooltip.mdx';

<IntegrationInstallTooltip/>

```bash npm
npm install @langchain/azure-dynamic-sessions @langchain/core
```

You'll also need to have a code interpreter session pool instance running. You can deploy a version using [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) following [this guide](https://learn.microsoft.com/azure/container-apps/sessions-code-interpreter).

Once you have your instance running, you need to make sure you have properly set up the Azure Entra authentication for it. You can find the instructions on how to do that [here](https://learn.microsoft.com/azure/container-apps/sessions?tabs=azure-cli#authentication).

After you've added the role for your identity, you need to retrieve the **session pool management endpoint**. You can find it in the Azure Portal, under the "Overview" section of your instance. Then you need to set the following environment variable:

import EnvVars from "/snippets/javascript-integrations/examples/tools/azure_dynamic_sessions/env-vars.mdx";

<EnvVars />

## Usage example

Below is a simple example that creates a new Python code interpreter session, invoke the tool and prints the result.

import AzureDynamicSessions from "/snippets/javascript-integrations/examples/tools/azure_dynamic_sessions/azure_dynamic_sessions.mdx";

<AzureDynamicSessions />

Here is a complete example where we use an Azure OpenAI chat model to call the Python code interpreter session tool to execute the code and get the result:

import AzureDynamicSessionsAgent from "/snippets/javascript-integrations/examples/tools/azure_dynamic_sessions/azure_dynamic_sessions_agent.mdx";

<AzureDynamicSessionsAgent />

## Related

- Tool [conceptual guide](/oss/langchain/tools)
- Tool [how-to guides](/oss/how-to/#tools)
